 function jisun(){
    	 a=parseInt($("#predepoit").html());
		 lv=parseInt($("#txfee").html());
		 b=$("#pdc_amount").val();
		 $("#sxfee").html(b*lv/100);
		 if(b>a){
			  errorTipsShow('您输入的金额不能大于'+a+'!');
			  $("#pdc_amount").val(a);
			   $("#sxfee").html(a*lv/100);
		}else if(b<100){
			 errorTipsShow('您输入的金额不能小于100!');
		}
}
$(function() {
    var key = getCookie('key');
    if (!key) {
        window.location.href = WapSiteUrl+'/tmpl/member/login.html';
        return;
    }
 $.getJSON(ApiUrl + "/index.php?act=member_index&op=my_asset", {
        key: key
    },
    function(e) {
		a=e.datas.predepoit;
		//b=parseInt(a/100);
        $("#predepoit").html(a);
		$("#predepoityc").html(a);
		$("#txfee").html(e.datas.site_shuifei);
    });
 

 $.ajax({
        type: "get",
        url: ApiUrl + "/index.php?act=member_account&op=get_paypwd_info",
        data: {
            key: key
        },
        dataType: "json",
        success: function(e) {
            if (e.code == 200) {
                if (e.datas.state) {
					
                   // $("#mobile").html(e.datas.mobile)
                } else {
                    location.href = WapSiteUrl + "/tmpl/member/member_paypwd_step1.html"
                }
            }
        }
    });

    $.sValid.init({
        rules:{
            pdc_amount:"required",
            pdc_bank_name:"required",
            pdc_bank_no:"required",
            pdc_bank_user:"required",
            password:"required",
        },
        messages:{
            pdc_amount:"请输入金额",
            pdc_bank_name:"请输入收款银行",
            pdc_bank_no:"请输入银行账号",
            pdc_bank_user:"请输入开户人姓名",
            password:"请输入支付密码",
        },
        callback:function (eId,eMsg,eRules){
            if(eId.length >0){
                var errorHtml = "";
                $.map(eMsg,function (idx,item){
                    errorHtml += "<p>"+idx+"</p>";
                });
                errorTipsShow(errorHtml);
            }else{
                errorTipsHide();
            }
        }
    });

    $('#saveform').click(function(){
							  
        if (!$(this).parent().hasClass('ok')) {
            return false;
        }
		

        if($.sValid()){
            var pdc_amount = $.trim($("#pdc_amount").val());
            var pdc_bank_name = $.trim($("#pdc_bank_name").val());
            var pdc_bank_no = $.trim($("#pdc_bank_no").val());
            var pdc_bank_user = $.trim($("#pdc_bank_user").val());
            var password = $.trim($("#password").val());
			if(pdc_amount%100!=0){
			    errorTipsShow('您输入的金额必需是100的倍数!');
				return false;
	     	}
            $.ajax({
                type:'post',
                url:ApiUrl+"/index.php?act=member_fund&op=pdrecharge_auth",
                data:{
				key:key,
				pdc_amount:pdc_amount,
				pdc_bank_name:pdc_bank_name,
				pdc_bank_no:pdc_bank_no,
				pdc_bank_user:pdc_bank_user,
				password:password,
				},
                dataType:'json',
                success:function(e){
                    if(e.code == 200){
						//TipsShow('<p>您的提现申请已成功提交，请等待系统处理</p>');
					 //toPay(e.datas.pay_sn, "member_buy", "pdrecharge_pay");
                        location.href = WapSiteUrl+'/tmpl/member/pdcashlist.html';
                    }else{
                      //  loadSeccode();
                        errorTipsShow('<p>' + result.datas.error + '</p>');
                    }
                }
            });
        }
    });
});
